//
//  LS_ListCollectionViewCell.m
//  App_6.23
//
//  Created by 芦珊 on 16/7/8.
//  Copyright © 2016年 lushan. All rights reserved.
//

#import "LS_ListCollectionViewCell.h"
#import "WH_Home.h"
@interface LS_ListCollectionViewCell ()

@property (nonatomic ,strong)UIImageView *headImg;
@property (nonatomic ,strong)UILabel *titleLabel;
@property (nonatomic ,strong)UILabel *bgPLabel;
@property (nonatomic ,strong)UILabel *realPLabel;

@end

@implementation LS_ListCollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

- (void)createSubView{
    
    self.headImg = [[UIImageView alloc] init];
    self.headImg.image = [UIImage imageNamed:@"aa.jpeg"];
    [self.contentView addSubview:self.headImg];
    [self.headImg mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.contentView.mas_left).offset(18);
        make.top.equalTo(self.contentView.mas_top).offset(10);
        make.width.height.equalTo(@(((SCREEN_WIDTH - 30) / 3) - 36));
        
    }];
    
    self.titleLabel = [[UILabel alloc] init];
    self.titleLabel.text = @"大家都静静的大家的基督教开烧烤";
    self.titleLabel.numberOfLines = 0;
    self.titleLabel.font = [UIFont systemFontOfSize:12];
    [self.contentView addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(5);
        make.top.equalTo(self.headImg.mas_bottom).offset(5);
        make.width.equalTo(@(((SCREEN_WIDTH - 30) / 3) - 10));
        make.height.equalTo(@(((SCREEN_HEIGHT / 5 * 2) - 109) / 5));
    }];
    
    self.bgPLabel = [[UILabel alloc] init];
    self.bgPLabel.backgroundColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1];
    self.bgPLabel.layer.cornerRadius = 3;
    self.bgPLabel.layer.masksToBounds = YES;
    [self.contentView addSubview:self.bgPLabel];
    [self.bgPLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
        make.width.equalTo(@(((SCREEN_WIDTH - 30) / 3) - 36));
        make.left.equalTo(self.contentView.mas_left).offset(18);
        make.height.equalTo(@6);
    }];
    
    self.realPLabel = [[UILabel alloc] init];
    self.realPLabel.backgroundColor = [UIColor colorWithRed:0.99 green:0.79 blue:0.27 alpha:1];
    self.realPLabel.layer.cornerRadius = 3;
    self.realPLabel.layer.masksToBounds = YES;
    [self.contentView addSubview:self.realPLabel];
    [self.realPLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(10);
        make.width.equalTo(@((((SCREEN_WIDTH - 30) / 3) - 36) * 0.5));
        make.left.equalTo(self.contentView.mas_left).offset(18);
        make.height.equalTo(@6);
    }];
    
}
- (void)setHomeModel:(WH_Home *)homeModel{
    if (_homeModel != homeModel) {
        _homeModel = homeModel;
    }
    [self.headImg sd_setImageWithURL:[NSURL URLWithString:homeModel.product_image] placeholderImage:PLACEHOLDER_CELL_SAME];
    self.titleLabel.text = homeModel.product_name;
    //self.nubLabel.text = [NSString stringWithFormat:@"%ld",self.cellHome.product_rate];
    [self.realPLabel mas_updateConstraints:^(MASConstraintMaker *make) {
        make.width.equalTo(@((((SCREEN_WIDTH - 30) / 3) - 36) * 0.4));
    }];
}
@end
